package com.example.development.jvmStudy.oom;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: vince_zww
 * @date: 2020/8/27 15:07
 * @desceription: 模拟堆 内存溢出
 *
 * JVM运行参数记得必须设置： -Xms10M -Xmx10M
 */
public class JavaHeapOOM {
    public static void main(String[] args) {
        long counter = 0;
        List<Object> list = new ArrayList<Object>();
        while (true){
            list.add(new Object());
            System.out.println("当前创建了第"+(++counter)+"个对象");
        }
    }
}
